/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jason.web.tag.dao;

import com.cn.lotary.base.dao.BaseEMDao;
import com.jason.web.tag.entity.Category;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.Query;

/**
 *
 * @author jason
 */
@Stateless
public class BaseCategoryDao extends BaseEMDao<Category> {

    public List<Category> getRootNode() {
        getEntityManager().getEntityManagerFactory().getCache().evict(Category.class);
        Query query = getEntityManager().createQuery("SELECT o FROM Category o WHERE o.parentCategory is null");
        //query.setHint(QueryHints.CACHE_STORE_MODE, QueryHints.REFRESH);
        return query.getResultList();
    }

    @Override
    public Class<Category> getEntityClass() {
        return Category.class;
    }
}
